<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jedrzej\Pimpable\PimpableTrait;

class UserExtract extends Model
{
    use HasFactory;
    use PimpableTrait;


    /**
     * 可执行搜索的字段
     */
    public $searchable = [
        'id',
        'user_id',
        'real_name',
        'extract_type',
        'status',
        'alipay_code',
        'wechat_name',
        'bank_code'
    ];

    /**
     * 提现类型
     */
    public $extractTypeEnum=[
        'bank' => '银行卡',
        'alipay' => '支付宝',
        'wechat' => '微信'
    ];

    /**
     * 提现状态
     */
    public $statusEnum=[
        'fail' => '未通过',
        'underreview' => '申请中',
        'withdrawncash' => '已提现'
    ];

    /**
     * 可批量赋值字段
     */
    public $fillable = [
        'user_id',
        'real_name',
        'extract_type',
        'bank_code',
        'bank_address',
        'alipay_code',
        'extract_price',
        'remarks',
        'balance',
        'fail_msg',
        'fail_time',
        'status',
        'wechat_code',
        'qrcode_url',
    ];

    /**
     * 进行排序的字段
     */
    public $sortable =[
        'extract_type',
        'extract_price',
        'fail_time',
    ];

    /**
     * 默认使用倒叙的字段
     */
    public $defaultSortCriteria = [
        'id,desc',
    ];

    /**
     * 账单关联用户的id
     */
    public function user()
    {
        return $this->belongsTo(User::class,'user_id','id');
    }


}
